package com.chixing.service.impl;

import co.elastic.clients.elasticsearch._types.query_dsl.WrapperQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chixing.entity.OrderDetail;
import com.chixing.mapper.OrderDetailMapper;
import com.chixing.service.IOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chixing.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author smith
 * @since 2025-09-30
 */
@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements IOrderDetailService {

    @Autowired
    private OrderDetailMapper orderDetailMapper;

    @Override
    public Result selectByOrderId(Long orderId) {

        QueryWrapper<OrderDetail> orderDetailWrapperQuery = new QueryWrapper<>();

        orderDetailWrapperQuery.eq("order_id",orderId);

        OrderDetail orderDetail = orderDetailMapper.selectOne(orderDetailWrapperQuery);

        if(orderDetail != null )
            return Result.getSuccess(orderDetail);

        return Result.getFail(null);
    }
}
